package com.sumainfor.pc.gmio.controller.Invoice;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.service.SeTenantBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Meng
 * @ClassName InvoiceController
 * @date 2019/4/28 15:37
 * @description: TODO
 */
@RestController
@RequestMapping("/tenant/key/invoice")
public class InvoiceController {

    @Autowired
    public SeTenantBillService seTenantBillService;

    /**
     * 功能描述: 
     * 根据租客编号获取租客待开发票列表
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/5 17:19
     */
    @GetMapping("/listTenantBillHavePaid")
    public JsonResult listTenantBillHavePaid(@RequestParam Map<String,Object> params){
        Pager pager=new Pager();
        JsonResult result = new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"TenId"})){
            result.putFailed("TenId不能为空！");
            return result;
        }
        params.put("BiType","1");
        params.put("DepositType","1");
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer count=seTenantBillService.getTenantBillHavePaidCount(params);
        if(count==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,count);
        }
        List<Map<String,Object>> listTenantBillHavePaid=seTenantBillService.listTenantBillHavePaid(params);
        result=pageUtils.getJsonResult(listTenantBillHavePaid, params, count);
        return result;
    }


}
